//+------------------------------------------------------------------+ //| RTS 1.1.2.mq4 | //| by TaXiRaN | //| No Copyright, created 2 Jun 2006, Open Source | //| http://www.forex-tsd.com | //| Freely receive, Freely give. Please post updated version. | //+------------------------------------------------------------------+ #property copyright "Created in 2006, Open Source Project by TaXiRaN" #property link "http://www.forex-tsd.com" extern int idBASE = 100000; // Change this number if running more than one EA on the same pair. extern double Lots = 0.10; extern int TakeProfit = 80; extern int InitialStop = 20; extern bool Alerts = true; extern string StepStops = "Trailing Stops Options"; extern bool UseStepStops = false; // This will use the StepStops() Function. extern int BreakEven = 10; // Move StopLoss to Order Open Price. extern int TSactivation = 5; // TSactivation will set the point where the Trailing will start. extern int StepSize = 5; extern int MinDistance = 10; // Min Distance between StopLoss and Market Price. extern bool CheckExit = true; // extern string TimeTrade = "An Options For Using Hour Trade"; extern bool UseHourTrade = false; // Time Filter. extern int FromHourTrade = 1; // Start Trading on this Hour. extern int ToHourTrade = 11; // End Trading on this Hour. int ID; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init(){ ID=idBASE; return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { if (UseStepStops){ if (ExistPositions()){ StepStops(); } } if (UseHourTrade){ if (!(Hour()>=FromHourTrade && Hour()<=ToHourTrade)){ Comment("\n|| Out of Trading Time"); return(0); } } if(AccountFreeMargin()<(1000*Lots)){ Comment("\n|| Free Margin = ",AccountFreeMargin(),"\n|| We have no money."); return(0); } if (!ExistPositions()){ CheckOpen(); } if (CheckExit && ExistPositions()){ CheckExit(); } } ////////////////////////////////////////////////////////////////////////////////////////////// void CheckOpen() { if (Juice() ==1){ if (StopReversal() ==1 && CoG() ==1){ // up trend for BUY signal. OpenBuy(); return(0); } if (StopReversal() ==2 && CoG() ==2){ // down trend for SELL signal. OpenSell(); return(0); } } } ////////////////////////////////////////////////////////////////////////////////////////////// int CheckExit() { if (OrderType()==OP_BUY){ if (Juice() ==2 || CoG() ==2){ OrderClose(OrderTicket(),OrderLots(),Bid,2,Aqua); } } if (OrderType()==OP_SELL){ if (Juice() ==2 || CoG() ==1){ OrderClose(OrderTicket(),OrderLots(),Ask,2,Magenta); } } } ////////////////////////////////////////////////////////////////////////////////////////////// int Juice() { double Juice0=iCustom(NULL,15,"Juice",7,0.0004,0,0); double Juice1=iCustom(NULL,5,"Juice",7,0.0004,0,0); if (Juice0>0.0006 && Juice1>0.0004) return(1); // Trend if (Juice0<0.0006 && Juice1<0.0004) return(2); // Rang } ////////////////////////////////////////////////////////////////////////////////////////////// int StopReversal() { int bars=Bars; for (int i=0; i<=bars; i++){ bool up = iCustom(NULL,5,"StopReversal",0.001,0,i); bool dw = iCustom(NULL,5,"StopReversal",0.001,1,i); if (up==true){ return(1); break; } if (dw==true){ return(2); break; } } } ////////////////////////////////////////////////////////////////////////////////////////////// int CoG() { double CoG1=iCustom(NULL,15,"Center of Gravity",10,200,0,0); // Green Line double CoG2=iCustom(NULL,15,"Center of Gravity",10,200,1,0); // Red Line if (CoG1>CoG2) return(1); // UP if (CoG10 || OrderStopLoss()==0){ if (Bid-OrderOpenPrice()>=BreakEven*Point && !BE){ BuyStop = OrderOpenPrice(); BE=true; } if (OrderStopLoss()==0){ BuyStop = OrderOpenPrice()-InitialStop*Point; k = 1; BE=false; } if (Bid-OrderOpenPrice()>=TSactivation*Point){ if (Bid-OrderOpenPrice()>=k*StepSize*Point){ BuyStop = OrderStopLoss()+StepSize*Point; if (Bid-BuyStop>=MinDistance*Point){ BuyStop = BuyStop; k = k+1; }else BuyStop = OrderStopLoss(); } } OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(BuyStop, digit),OrderTakeProfit(),0,LightGreen); return(0); } } if (mode==OP_SELL){ SellStop = OrderStopLoss(); if (OrderOpenPrice()-Ask>0 || OrderStopLoss()==0){ if (OrderOpenPrice()-Ask>=BreakEven*Point && !BE){ SellStop = OrderOpenPrice(); BE=true; } if (OrderStopLoss()==0){ SellStop = OrderOpenPrice()+InitialStop*Point; k = 1; BE=false; } if (OrderOpenPrice()-Ask>=TSactivation*Point){ if (OrderOpenPrice()-Ask>=k*StepSize*Point){ SellStop = OrderStopLoss()-StepSize*Point; if (SellStop-Ask>=MinDistance*Point){ SellStop = SellStop; k = k+1; }else SellStop = OrderStopLoss(); } } OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(SellStop, digit),OrderTakeProfit(),0,Yellow); return(0); } } } } } ////////////////////////////////////////////////////////////////////////////////////////////// גuL@N0uO<[2&;Q H+u\7@oKSJQ8R.ETN}.;YV(ɷM!R酏\m;LTmZZ"?% .|6G;n5+IS}6*lyc +A7eq(i0j񜕠ttޡM$)͢zU?[݋vlkV.M,R꽫DkR%5"wݒOy3 "8J6?%Q<*/]]ET>Ð:+XZB)[Oy~r۴HJ;n2C45tڃVED~(E_O 1=2_yMY;dGh*O]<[W789Jn xrQ_-HwgMb1b*=8? >OɐruH.rVa PsRW~Zv ÿ/z}}U==ztǍ!C5{!vӞ2/'U* _~mj/,K?x.6YݏkO6:ߎo=mz\?r鶆eú,2XӼ["< v=?MnNGbqf-ni/v/ǐ\<3'E$ďI6\ė| X%]/!],i$!_@~Ws)U>j5YQVwV [ !_VdC2ǁ`x~Z0࣑qT Ac43 tmD"SmNj%G⻭ӺUNPs{ 걗Rq-Y%Y wWQ KbN_< _\7wB7Rwu볭Kӓޔoצf;RBNQ?U}\-&mA\XJKS@т224U]ȅE_|nYn;rQiÎڦQ_?8b-Ba֖F,v=!e.[m;"•}Mqgß2G ;ăw0 SN܊ZʍdC2kӇ;[Lڒyj;6jD*,W8:Ѕ,׫IJ_*q*D;>XA x Xa9[!}I+nm|m(++=>iE}?!~g"r1h,5dwGNp|nDx*]e{kZmT8!$:EO3Ms=Ǚ6~z9,PNUlsJIl<[қ|iszc[#DM'gn m>( OuF֘zUdޥk$6(2I a߽Ύ¤N^*`dnC&tf wNj mpj Tň{-c; skA0wsw. '^4H|Oi:^#?%kl|Xy~۽mX9Q窭% nF^(IKI_m'/+\>u}#S'󇹠i4vsݘ}sW2Rr&F]QgݖD#`"! T{o[wΙ1>"|U#CTr##묏[.R8|vwrga9?75wŷi ໣̫ǀxzzC ES}'NX\w1QpuSo'f@gJsAִ60y&bH.G{O$.g_ݸAzY `^z>Nw>/}q}Q@ A]:%P4?ִJ'p8t7 f-HF?ηV>=I\H4Ly|Q^08s@w1KJ+Jpՠ)rXߡvxDYwd?}n_Hgœb) O*